<!doctype html>



  


<html class="theme-next pisces use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  
    
      
    

    
  

  
    
      
    

    
  

  
    
      
    

    
  

  
    
      
    

    
  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Microsoft YaHei:300,300italic,400,400italic,700,700italic|Microsoft YaHei:300,300italic,400,400italic,700,700italic|Microsoft YaHei:300,300italic,400,400italic,700,700italic|Microsoft YaHei:300,300italic,400,400italic,700,700italic|Microsoft YaHei:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="java,jvm," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta name="description" content="PreludeJava class file ( produced by java compiler ,  whose naming format is *.class ) can be executed by Java Virtual Machine  ( also called JVM  ) .  For JVM is available for many platforms , java l">
<meta property="og:type" content="article">
<meta property="og:title" content="research in java class file">
<meta property="og:url" content="http://yoursite.com/2017/02/25/research-in-java-class-file/index.html">
<meta property="og:site_name" content="Arvin Alfod">
<meta property="og:description" content="PreludeJava class file ( produced by java compiler ,  whose naming format is *.class ) can be executed by Java Virtual Machine  ( also called JVM  ) .  For JVM is available for many platforms , java l">
<meta property="og:updated_time" content="2017-05-30T15:06:19.544Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="research in java class file">
<meta name="twitter:description" content="PreludeJava class file ( produced by java compiler ,  whose naming format is *.class ) can be executed by Java Virtual Machine  ( also called JVM  ) .  For JVM is available for many platforms , java l">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: 'Author'
    }
  };
</script>

  <title> research in java class file | Arvin Alfod </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="en">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">Arvin Alfod</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle"></p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            About
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            Tags
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                research in java class file
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2017-02-25T21:40:59+08:00" content="2017-02-25">
              2017-02-25
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Technology/" itemprop="url" rel="index">
                    <span itemprop="name">Technology</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="Prelude"><a href="#Prelude" class="headerlink" title="Prelude"></a>Prelude</h1><p>Java class file ( produced by java compiler ,  whose naming format is *.class ) can be executed by <em>Java Virtual Machine</em>  ( also called <strong>JVM</strong>  ) .  For JVM is available for many platforms , java language obtain its precious features  <strong>Platforms Independent</strong> which means <strong>once write , run anywhere</strong>.<br>Many java programmers can be curious about it , let’s share a journey of exploration !<br>For purpose of  giving a profile to beginners , this blog will focus on the analysis  of source code . not  the comprehensive illuminate of JVM .</p>
<h1 id="Class-File-Structure"><a href="#Class-File-Structure" class="headerlink" title="Class File Structure"></a>Class File Structure</h1><ul>
<li><p><strong>Magic  Number</strong><br>Only java class file’s first 4 bytes code is｜ “0xCAFEBABE” , which give JVM a fast way to verify a file’s format  .</p>
</li>
<li><p><strong>Version Number</strong><br>The next 4 bytes indicate the java version of this class file , in which the first two bytes represented minor version name , while  the other two bytes represented major version .</p>
</li>
<li><p><strong>Constant pool</strong><br>This section can be broken into two parts ,  pool count in first 2 bytes and the rest  is constant pool table , which store Strings , numbers  and references to classes and methods .</p>
</li>
</ul>
<h1 id="Basic-Tools"><a href="#Basic-Tools" class="headerlink" title="Basic Tools"></a>Basic Tools</h1><ul>
<li><p><em>javac  $SourceFilePath</em></p>
<pre><code>javac will compile java code to class file .
</code></pre></li>
<li><p><em>javap -verbose $ClassPath</em>      </p>
<pre><code>javap  will disassembles a class file to  human-readable  format , we will analyze the result file to understand how class file describe  the java source code
</code></pre></li>
</ul>
<h1 id="Examples"><a href="#Examples" class="headerlink" title="Examples"></a>Examples</h1><ul>
<li><strong>For Loop</strong></li>
</ul>
<p><em>Source Code</em><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">package com.alfod;</div><div class="line"></div><div class="line">public class JavaByteCode &#123;</div><div class="line">    public int additionFromTo(int a, int b) &#123;</div><div class="line">            for (int i = a; i &lt; b; i++) &#123;</div><div class="line">                a=b+a+i;</div><div class="line">            &#125;</div><div class="line">            return a;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p><em>Byte Code</em></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div></pre></td><td class="code"><pre><div class="line">  Compiled from &quot;JavaByteCode.java&quot;</div><div class="line">public class com.alfod.JavaByteCode</div><div class="line">  minor version: 0</div><div class="line">  major version: 52</div><div class="line">  flags: ACC_PUBLIC, ACC_SUPER</div><div class="line">Constant pool:</div><div class="line">   #1 = Methodref          #3.#14         // java/lang/Object.&quot;&lt;init&gt;&quot;:()V</div><div class="line">   #2 = Class              #15            // com/alfod/JavaByteCode</div><div class="line">   #3 = Class              #16            // java/lang/Object</div><div class="line">   #4 = Utf8               &lt;init&gt;</div><div class="line">   #5 = Utf8               ()V</div><div class="line">   #6 = Utf8               Code</div><div class="line">   #7 = Utf8               LineNumberTable</div><div class="line">   #8 = Utf8               LocalVariableTable</div><div class="line">   #9 = Utf8               this</div><div class="line">  #10 = Utf8               Lcom/alfod/JavaByteCode;</div><div class="line">  #11 = Utf8               fun</div><div class="line">  #12 = Utf8               SourceFile</div><div class="line">  #13 = Utf8               JavaByteCode.java</div><div class="line">  #14 = NameAndType        #4:#5          // &quot;&lt;init&gt;&quot;:()V</div><div class="line">  #15 = Utf8               com/alfod/JavaByteCode</div><div class="line">  #16 = Utf8               java/lang/Object</div><div class="line">&#123;</div><div class="line">  public com.alfod.JavaByteCode();</div><div class="line">    descriptor: ()V                      // this is  the  default init function of the class , usually produced by java compiler , Types in () means the arguments  for this method , right words indicate  the return type.</div><div class="line">    flags: ACC_PUBLIC              //method&apos;s access  permission is  public</div><div class="line">    Code:</div><div class="line">      stack=1, locals=1, args_size=1    //operand stack&apos;s depth is 1 , local variable  table&apos;s length  is 1 ,   arguments of this method is 1</div><div class="line">         0: aload_0                                                    </div><div class="line">         1: invokespecial #1                  //call initialization  Method java/lang/Object.&quot;&lt;init&gt;&quot;:()V</div><div class="line">         4: return</div><div class="line">      LineNumberTable:                        //this  table store the correspondence  of line numbers between  source code and byte code</div><div class="line">        line 3: 0</div><div class="line">      LocalVariableTable:                           // as the name suggests</div><div class="line">        Start  Length  Slot  Name   Signature</div><div class="line">            0       5     0  this   Lcom/alfod/JavaByteCode;</div><div class="line"></div><div class="line"></div><div class="line">public int additionFromTo(int, int);</div><div class="line">descriptor: (II)I</div><div class="line">flags: ACC_PUBLIC</div><div class="line">Code:</div><div class="line">  stack=2, locals=4, args_size=3</div><div class="line">     0: iload_1                                   //load  the second elememt ( value of  a )  of the LocalVariableTable  onto operand stack</div><div class="line">     1: istore_3                      //store the top of  stact ( just the value of a , loaded in last instruction ) in LocalVariableTable  at the  froth index ( where stores the value of variable i );  equals code &quot; i=a&quot;</div><div class="line">     2: iload_3        //push the  forth element  ( value of variable i ) of LocalVariableTable onto stack</div><div class="line">     3: iload_2    //push the third element ( value of variable b )  of LocalVariableTable onto stack</div><div class="line">     4: if_icmpge     19           //compare the value of the top two stack ,  for this instruction ,  if the result is false ( means &quot;i &lt; b&quot; )  execute the next instruction , if the result is false ( means that &quot;i &gt;=  b&quot; )   branch to instruction at number 19  </div><div class="line">     7: iload_2                 //push the third element ( value of variable b )  of LocalVariableTable onto stack</div><div class="line">     8: iload_1             //load  the second elememt ( value of  a )  of the LocalVariableTable  onto operand stack</div><div class="line">     9: iadd            //add two ints  loaded just now  ( equivalent to &quot;b+a &quot;)</div><div class="line">    10: iload_3         //push the  forth element  ( value of variable i ) of LocalVariableTable onto stack</div><div class="line">    11: iadd             //add two ints  ( one is the result of &quot; b+a &quot; , the other is &quot;i&quot; ,  equivalent to &quot;b+a+i &quot; )</div><div class="line">    12: istore_1     //store the result at the 1 in LocalVariableTable ( where stores the value of a )</div><div class="line">    13: iinc          3, 1              // increment LocalVariableTable at index 3 by 1 ( equivalent to &quot;i++&quot; )</div><div class="line">    16: goto          2                 //jump to line 2</div><div class="line">    19: iload_1                         //  //load  the second elememt ( value of  a )  of the LocalVariableTable  onto operand stack</div><div class="line">    20: ireturn.                //return stack top ( just the value of a loaded in last instruction )</div><div class="line">  LineNumberTable:</div><div class="line">    line 6: 0     //line number 6  ( &quot;for (int i = a; i &lt; b; i++) &#123;&quot;  ) in source code  correspondence to line number 0 ( &quot; 0: iload_1&quot; ) in  byte code</div><div class="line">    line 7: 7             //line number 7  in source code (  &quot; a=b+a+i;&quot; ) correspondence to line number 7 ( &quot; iload_2  &quot;)  in  byte code   </div><div class="line">    line 6: 13           //line number 6  ( &quot;for (int i = a; i &lt; b; i++) &#123;&quot;  ) in source code  correspondence to line number 0 ( &quot;iinc          3, 1&quot;  ) in  byte code</div><div class="line">    line 9: 19               //line number 9  ( &quot; return a; &quot;  ) in source code  correspondence to line number 0 ( &quot;iload_1&quot;  ) in  byte code</div><div class="line">  LocalVariableTable:</div><div class="line">    Start  Length  Slot  Name   Signature</div><div class="line">        2      17     3     i   I</div><div class="line">        0      21     0  this   Lcom/alfod/JavaByteCode;</div><div class="line">        0      21     1     a   I</div><div class="line">        0      21     2     b   I</div><div class="line">  StackMapTable: number_of_entries = 2</div><div class="line">    frame_type = 252 /* append */</div><div class="line">      offset_delta = 2</div><div class="line">      locals = [ int ]</div><div class="line">    frame_type = 250 /* chop */</div><div class="line">      offset_delta = 16</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<ul>
<li><strong>Accessor  And Mutator Of  Object</strong><br><em>Source Code</em><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">package com.alfod;</div><div class="line"></div><div class="line">public class JavaByteCode &#123;</div><div class="line">    private String name;</div><div class="line"></div><div class="line">    public void setName(String name) &#123;</div><div class="line">        this.name = name;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public String getName() &#123;</div><div class="line">        return this.name;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
</li>
</ul>
<p><em>Byte Code</em></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div></pre></td><td class="code"><pre><div class="line">public class com.alfod.JavaByteCode</div><div class="line">  minor version: 0</div><div class="line">  major version: 52</div><div class="line">  flags: ACC_PUBLIC, ACC_SUPER</div><div class="line">Constant pool:</div><div class="line">   #1 = Methodref          #4.#27         // java/lang/Object.&quot;&lt;init&gt;&quot;:()V</div><div class="line">   #2 = Fieldref           #3.#28         // com/alfod/JavaByteCode.name:Ljava/lang/String;</div><div class="line">   #3 = Class              #29            // com/alfod/JavaByteCode</div><div class="line">   #4 = Class              #30            // java/lang/Object</div><div class="line">   #5 = Utf8               name</div><div class="line">   #6 = Utf8               Ljava/lang/String;</div><div class="line">   #7 = Utf8               &lt;init&gt;</div><div class="line">   #8 = Utf8               ()V</div><div class="line">   #9 = Utf8               Code</div><div class="line">  #10 = Utf8               LineNumberTable</div><div class="line">  #11 = Utf8               LocalVariableTable</div><div class="line">  #12 = Utf8               this</div><div class="line">  #13 = Utf8               Lcom/alfod/JavaByteCode;</div><div class="line">  #14 = Utf8               additionFromTo</div><div class="line">  #15 = Utf8               (II)I</div><div class="line">  #16 = Utf8               i</div><div class="line">  #17 = Utf8               I</div><div class="line">  #18 = Utf8               a</div><div class="line">  #19 = Utf8               b</div><div class="line">  #20 = Utf8               StackMapTable</div><div class="line">  #21 = Utf8               setName</div><div class="line">  #22 = Utf8               (Ljava/lang/String;)V</div><div class="line">  #23 = Utf8               getName</div><div class="line">  #24 = Utf8               ()Ljava/lang/String;</div><div class="line">  #25 = Utf8               SourceFile</div><div class="line">  #26 = Utf8               JavaByteCode.java</div><div class="line">  #27 = NameAndType        #7:#8          // &quot;&lt;init&gt;&quot;:()V</div><div class="line">  #28 = NameAndType        #5:#6          // name:Ljava/lang/String;</div><div class="line">  #29 = Utf8               com/alfod/JavaByteCode</div><div class="line">  #30 = Utf8               java/lang/Object</div><div class="line">&#123;</div><div class="line">  public com.alfod.JavaByteCode();</div><div class="line">    descriptor: ()V</div><div class="line">    flags: ACC_PUBLIC</div><div class="line">    Code:</div><div class="line">      stack=1, locals=1, args_size=1</div><div class="line">         0: aload_0</div><div class="line">         1: invokespecial #1                  // Method java/lang/Object.&quot;&lt;init&gt;&quot;:()V</div><div class="line">         4: return</div><div class="line">      LineNumberTable:</div><div class="line">        line 3: 0</div><div class="line">      LocalVariableTable:</div><div class="line">        Start  Length  Slot  Name   Signature</div><div class="line">            0       5     0  this   Lcom/alfod/JavaByteCode;</div><div class="line"></div><div class="line">public void setName(java.lang.String);</div><div class="line">    descriptor: (Ljava/lang/String;)V</div><div class="line">    flags: ACC_PUBLIC</div><div class="line">    Code:</div><div class="line">      stack=2, locals=2, args_size=2</div><div class="line">         0: aload_0      //     load a reference from LocalVariableTable at index 0 ( this pointer )               </div><div class="line">         1: aload_1   // load a reference from LocalVariableTable at index  1 ( method&apos;s argument &quot;name&quot;  )</div><div class="line">         2: putfield      #2                  //assign the value of &apos; name &apos; to the attribute named &apos;name&apos; of this  ;</div><div class="line">         5: return  </div><div class="line">      LineNumberTable:</div><div class="line">        line 14: 0</div><div class="line">        line 15: 5</div><div class="line">      LocalVariableTable:</div><div class="line">        Start  Length  Slot  Name   Signature</div><div class="line">            0       6     0  this   Lcom/alfod/JavaByteCode;</div><div class="line">            0       6     1  name   Ljava/lang/String;</div><div class="line"></div><div class="line">  public java.lang.String getName();</div><div class="line">    descriptor: ()Ljava/lang/String;</div><div class="line">    flags: ACC_PUBLIC</div><div class="line">    Code:</div><div class="line">      stack=1, locals=1, args_size=1</div><div class="line">         0: aload_0                     //load a  reference from LocalVariableTable at index 0 ( this pointer )</div><div class="line">         1: getfield      #2                  // push the value of this&apos;s attribute &apos;name&apos; onto stack</div><div class="line">         4: areturn</div><div class="line">      LineNumberTable:</div><div class="line">        line 18: 0</div><div class="line">      LocalVariableTable:</div><div class="line">        Start  Length  Slot  Name   Signature</div><div class="line">            0       5     0  this   Lcom/alfod/JavaByteCode;</div><div class="line">&#125;</div><div class="line">SourceFile: &quot;JavaByteCode.java&quot;</div></pre></td></tr></table></figure>
<ul>
<li><strong>Genericity</strong><br><em>Source Code</em><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">package com.alfod;</div><div class="line"></div><div class="line">import java.util.LinkedList;</div><div class="line">import java.util.List;</div><div class="line"></div><div class="line">public class JavaGenericity &#123;</div><div class="line">    public List&lt;String&gt; toList(String... strings)&#123;</div><div class="line">        List&lt;String&gt; list=new LinkedList&lt;&gt;();</div><div class="line">        for(String s:strings)&#123;</div><div class="line">            list.add(s);</div><div class="line">        &#125;</div><div class="line">        return list;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
</li>
</ul>
<p><em>Byte Code</em><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div></pre></td><td class="code"><pre><div class="line">public class com.alfod.JavaGenericity</div><div class="line">  minor version: 0</div><div class="line">  major version: 52</div><div class="line">  flags: ACC_PUBLIC, ACC_SUPER</div><div class="line">Constant pool:</div><div class="line">   #1 = Methodref          #6.#32         // java/lang/Object.&quot;&lt;init&gt;&quot;:()V</div><div class="line">   #2 = Class              #33            // java/util/LinkedList</div><div class="line">   #3 = Methodref          #2.#32         // java/util/LinkedList.&quot;&lt;init&gt;&quot;:()V</div><div class="line">   #4 = InterfaceMethodref #34.#35        // java/util/List.add:(Ljava/lang/Object;)Z</div><div class="line">   #5 = Class              #36            // com/alfod/JavaGenericity</div><div class="line">   #6 = Class              #37            // java/lang/Object</div><div class="line">   #7 = Utf8               &lt;init&gt;</div><div class="line">   #8 = Utf8               ()V</div><div class="line">   #9 = Utf8               Code</div><div class="line">  #10 = Utf8               LineNumberTable</div><div class="line">  #11 = Utf8               LocalVariableTable</div><div class="line">  #12 = Utf8               this</div><div class="line">  #13 = Utf8               Lcom/alfod/JavaGenericity;</div><div class="line">  #14 = Utf8               toList</div><div class="line">  #15 = Utf8               ([Ljava/lang/String;)Ljava/util/List;</div><div class="line">  #16 = Utf8               s</div><div class="line">  #17 = Utf8               Ljava/lang/String;</div><div class="line">  #18 = Utf8               strings</div><div class="line">  #19 = Utf8               [Ljava/lang/String;</div><div class="line">  #20 = Utf8               list</div><div class="line">  #21 = Utf8               Ljava/util/List;</div><div class="line">  #22 = Utf8               LocalVariableTypeTable</div><div class="line">  #23 = Utf8               Ljava/util/List&lt;Ljava/lang/String;&gt;;</div><div class="line">  #24 = Utf8               StackMapTable</div><div class="line">  #25 = Class              #36            // com/alfod/JavaGenericity</div><div class="line">  #26 = Class              #19            // &quot;[Ljava/lang/String;&quot;</div><div class="line">  #27 = Class              #38            // java/util/List</div><div class="line">  #28 = Utf8               Signature</div><div class="line">  #29 = Utf8               ([Ljava/lang/String;)Ljava/util/List&lt;Ljava/lang/String;&gt;;</div><div class="line">  #30 = Utf8               SourceFile</div><div class="line">  #31 = Utf8               JavaGenericity.java</div><div class="line">  #32 = NameAndType        #7:#8          // &quot;&lt;init&gt;&quot;:()V</div><div class="line">  #33 = Utf8               java/util/LinkedList</div><div class="line">  #34 = Class              #38            // java/util/List</div><div class="line">  #35 = NameAndType        #39:#40        // add:(Ljava/lang/Object;)Z</div><div class="line">  #36 = Utf8               com/alfod/JavaGenericity</div><div class="line">  #37 = Utf8               java/lang/Object</div><div class="line">  #38 = Utf8               java/util/List</div><div class="line">  #39 = Utf8               add</div><div class="line">  #40 = Utf8               (Ljava/lang/Object;)Z</div><div class="line">&#123;</div><div class="line">  public com.alfod.JavaGenericity();</div><div class="line">    descriptor: ()V</div><div class="line">    flags: ACC_PUBLIC</div><div class="line">    Code:</div><div class="line">      stack=1, locals=1, args_size=1</div><div class="line">         0: aload_0</div><div class="line">         1: invokespecial #1                  // Method java/lang/Object.&quot;&lt;init&gt;&quot;:()V</div><div class="line">         4: return</div><div class="line">      LineNumberTable:</div><div class="line">        line 9: 0</div><div class="line">      LocalVariableTable:</div><div class="line">        Start  Length  Slot  Name   Signature</div><div class="line">            0       5     0  this   Lcom/alfod/JavaGenericity;</div><div class="line"></div><div class="line">  public java.util.List&lt;java.lang.String&gt; toList(java.lang.String...);</div><div class="line">    descriptor: ([Ljava/lang/String;)Ljava/util/List;</div><div class="line">    flags: ACC_PUBLIC, ACC_VARARGS</div><div class="line">    Code:</div><div class="line">      stack=2, locals=7, args_size=2</div><div class="line">         0: new           #2                  // initialize the class java/util/LinkedList and push the reference onto stack</div><div class="line">         3: dup         //duplicate the  top element of stack</div><div class="line">         4: invokespecial #3                  // perform the initialization of LinkedList and push the reference onto the stack</div><div class="line">         7: astore_2        //store the reference of LinkedList on the stack in LocalVariableTable at index 2</div><div class="line">         8: aload_1     //load the element of LocalVariableTable at index 1 onto stack</div><div class="line">         9: astore_3    //store the reference on stack in LocalVariableTable at index 3</div><div class="line">        10: aload_3      //load the element of LocalVariableTable at index 3 onto stack</div><div class="line">        11: arraylength     //get the length of  array loaded last instruction  and push on to stack</div><div class="line">        12: istore        4         //store the length in LocalVariableTable at index  4</div><div class="line">        14: iconst_0        //load the int value 0 onto the stack</div><div class="line">        15: istore        5         //store the int value 0 in LocalVariableTable  at index 5</div><div class="line">        17: iload         5             //load the element from LocalVariableTable at index 5 onto stack</div><div class="line">        19: iload         4         //load the length of arguments array length</div><div class="line">        21: if_icmpge     45        //compare the arguments array length and the value in LocalVariableTable at index 5 , if array lenght is less than the value in LocalVariableTable at index 5 , then goto line number 45</div><div class="line">        24: aload_3         //load  the tmp String reference &apos;s&apos;</div><div class="line">        25: iload         5         //load the element of LocalVariableTable at index 5</div><div class="line">        27: aaload          // get the value of element   arguments array whose index is the value of element from LocalVariableTable at index 5</div><div class="line">        28: astore        6         //store the value get in last instruction in LocalVariableTable at index 6</div><div class="line">        30: aload_2         //push the reference of list  onto stack</div><div class="line">        31: aload         6         //push the value in LocalVariableTable at index 6 onto stack</div><div class="line">        33: invokeinterface #4,  2            //the list add the value in LocalVariableTable at index 6  </div><div class="line">        38: pop     //pop the top element of stack</div><div class="line">        39: iinc          5, 1      //the tmp value in LocalVariableTable at index 5 add 1</div><div class="line">        42: goto          17            //goto line number 17</div><div class="line">        45: aload_2         //load the list reference</div><div class="line">        46: areturn     //return the list reference</div><div class="line">      LineNumberTable:</div><div class="line">        line 11: 0</div><div class="line">        line 12: 8</div><div class="line">        line 13: 30</div><div class="line">        line 12: 39</div><div class="line">        line 15: 45</div><div class="line">      LocalVariableTable:</div><div class="line">        Start  Length  Slot  Name   Signature</div><div class="line">           30       9     6     s   Ljava/lang/String;</div><div class="line">            0      47     0  this   Lcom/alfod/JavaGenericity;</div><div class="line">            0      47     1 strings   [Ljava/lang/String;</div><div class="line">            8      39     2  list   Ljava/util/List;</div><div class="line">      LocalVariableTypeTable:</div><div class="line">        Start  Length  Slot  Name   Signature</div><div class="line">            8      39     2  list   Ljava/util/List&lt;Ljava/lang/String;&gt;;</div><div class="line">      StackMapTable: number_of_entries = 2</div><div class="line">        frame_type = 255 /* full_frame */</div><div class="line">          offset_delta = 17</div><div class="line">          locals = [ class com/alfod/JavaGenericity, class &quot;[Ljava/lang/String;&quot;, class java/util/List, class &quot;[Ljava/lang/String;&quot;, int, int ]</div><div class="line">          stack = []</div><div class="line">        frame_type = 248 /* chop */</div><div class="line">          offset_delta = 27</div><div class="line">    Signature: #29                          // ([Ljava/lang/String;)Ljava/util/List&lt;Ljava/lang/String;&gt;;</div><div class="line">&#125;</div><div class="line">SourceFile: &quot;JavaGenericity.java&quot;</div></pre></td></tr></table></figure></p>

      
    </div>

    <div>
      
        
      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/java/" rel="tag">#java</a>
          
            <a href="/tags/jvm/" rel="tag">#jvm</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/03/03/spring-mvc-interceptor/" rel="prev" title="HandlerInterceptorAdapter">
                HandlerInterceptorAdapter <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            Overview
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avator.jpg"
               alt="Arvin Alfod" />
          <p class="site-author-name" itemprop="name">Arvin Alfod</p>
          <p class="site-description motion-element" itemprop="description"></p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">2</span>
              <span class="site-state-item-name">posts</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">1</span>
                <span class="site-state-item-name">categories</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">3</span>
                <span class="site-state-item-name">tags</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://www.facebook.com/arvin.alfod" target="_blank" title="Facebook">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  Facebook
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://github.com/alfod" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/arvinalfod" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.quora.com/profile/Arvin-Alfod" target="_blank" title="Quora">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  Quora
                </a>
              </span>
            
          
        </div>

        
        

        
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Prelude"><span class="nav-number">1.</span> <span class="nav-text">Prelude</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Class-File-Structure"><span class="nav-number">2.</span> <span class="nav-text">Class File Structure</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Basic-Tools"><span class="nav-number">3.</span> <span class="nav-text">Basic Tools</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Examples"><span class="nav-number">4.</span> <span class="nav-text">Examples</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2016-12 - 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Arvin Alfod</span>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.0.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  



  



  
  
  

  

  

</body>
</html>
